﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using spbtzb;

public partial class UserControls_MorePart : System.Web.UI.UserControl
{
    //protected string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='E://spbtzb.mdb';";
    protected string strConnection = spbtzb.ConString.ConnString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindControl(rpEconomy, "FGJJ");
            BindControl(rpNation, "MZZJ");
            BindControl(rpOversea, "GATH");
            BindControl(rpParty, "DDHZ");
            BindControl(rpTheory, "ZYZY");
        }
    }
    protected void BindControl(Repeater rp, string type)
    {
        rp.DataSource = AccessHelper.ExecuteDataTable(strConnection, CommandType.Text, String.Format(
            "SELECT TOP 4 A.ID,A.Title,A.CreateTime,A.TypeCode,B.ContentType From Contents A,ContentAndType B, ContentType C "+
            "WHERE A.ID=B.ContentID AND B.TypeID= C.ID AND( C.TypeCode='{0}' OR C.ParentType='{0}')",type));
       
        rp.DataBind();
    }

    protected string ConvertString(string title)
    {
        if (title.Length > 13)
        {
            title = title.Substring(0, 13);
            return title + "...";
        }
        return title;
       
    }
    protected string ConvertTime(object time)
    {
        if (time is Nullable) return "";
        try
        {
            DateTime dt = DateTime.Parse(time.ToString());
            return dt.Year.ToString()+"-"+ dt.Month.ToString() + "-" + dt.Day.ToString();
        }
        catch { }
        return "";
    }
}
